package com.xiaoshuidi.cloud.module.report.controller.datamanage;

import com.xiaoshuidi.cloud.framework.common.pojo.CommonResult;
import com.xiaoshuidi.cloud.module.report.controller.datamanage.vo.*;
import com.xiaoshuidi.cloud.module.report.enums.ApiConstants;
import com.xiaoshuidi.cloud.module.report.service.datamanage.FinancialAnalysisService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 财务统计
 */
@Slf4j
@Validated
@RestController
@RequestMapping(ApiConstants.DATA_MANAGE + "/finance-analysis")
public class FinanceController {

    @Resource
    private FinancialAnalysisService financialAnalysisService;


    /**
     * 应收逾期
     *
     * @param vo
     * @return
     */
    @PostMapping("/accountsReceivableOverdue")
    public CommonResult<OverdueColumnChartRespVO> accountsReceivableOverdue(@RequestBody LeaseAnalysisReqVO vo) {
        return CommonResult.success(financialAnalysisService.accountsReceivableOverdue(vo));
    }

    /**
     * 逾期付款
     *
     * @param vo
     * @return
     */
    @PostMapping("/overduePayments")
    public CommonResult<OverdueColumnChartRespVO> overduePayments(@RequestBody LeaseAnalysisReqVO vo) {
        return CommonResult.success(financialAnalysisService.overduePayments(vo));
    }

    /**
     * 租金营收分析
     *
     * @param vo
     * @return
     */
    @PostMapping("/rentRevenueAnalysis")
    public CommonResult<RentRevenueAnalysisRespVO> rentRevenueAnalysis(@RequestBody LeaseAnalysisReqVO vo) {
        return CommonResult.success(financialAnalysisService.rentRevenueAnalysis(vo));
    }

    /**
     * 收缴率分析
     *
     * @param vo
     * @return
     */
    @PostMapping("/rentOrderRateAnalysis")
    public CommonResult<ContractRentOrderRateRespVO> rentOrderRateAnalysis(@RequestBody LeaseAnalysisReqVO vo) {
        return CommonResult.success(financialAnalysisService.rentOrderRateAnalysis(vo));
    }

    /**
     * 累计已收统计
     *
     * @param vo
     * @return
     */
    @PostMapping("/accumulatedReceivedSum")
    public CommonResult<AccumulatedReceivedVO> accumulatedReceivedSum(@RequestBody LeaseAnalysisReqVO vo) {
        return CommonResult.success(financialAnalysisService.accumulatedReceivedSum(vo));
    }
}
